﻿namespace Core.Singleton
{
    public abstract class Singleton<T> where T : class
    {
        private static object lockObj = new object();
        private static T ins = null;

        public static T Ins
        {
            get
            {
                if (ins == null)
                {
                    lock (lockObj)
                    {
                        if (ins == null)
                        {
                            System.Type type = typeof(T);
                            ins = System.Activator.CreateInstance(type, true) as T;
                        }
                    }
                }

                return ins;
            }
        }
    }
}